<%--
  Created by IntelliJ IDEA.
  User: liu
  Date: 2018/9/10
  Time: 16:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<script src="js/jquery-1.11.3.min.js"></script>
<script src="js/layui/layui.js"></script>
<link rel="stylesheet" type="text/css" href="js/layui/css/layui.css"/>
<body>
<div class="layui-btn" id="start" onclick="add()">新增</div>
    <table id="table" lay-filter="table"></table>
</body>
<script type="application/javascript">
    var layer;
    var table;
    layui.use(['table', 'layer'], function () {
        table = layui.table;
        layer = layui.layer;

        table.render({
            elem: '#table',
            id:"table"
            , url: '/entityList'
            , cols: [[ //标题栏
                {field: 'name', title: '节目名',event:"edit"},
                {field: 'gro', title: '环节',event:"edit"},

            ]]
            , skin: 'row' //表格风格
            , even: true
            , page: false //是否显示分页
            , method: 'get',
            response: {
                statusName: 'statusCode' //数据状态的字段名称，默认：code
                , statusCode: 200 //成功的状态码，默认：0
                , msgName: 'statusMsg' //状态信息的字段名称，默认：msg
                , countName: 'totalPages' //数据总数的字段名称，默认：count
                , dataName: 'data' //数据列表的字段名称，默认：data
            },
        });
        //监听工具条
        table.on('tool(table)', function (obj) {
            var data = obj.data; //获得当前行数据
            add(data.id)
        });
    })


    function add(id) {
        var url="/entityItem?id="+id
        layer.open({
            type: 2,
            title: title,
            shade: 0.3,
            border: [0, 0.8, '#077ce0'],
            maxmin: false,
            area: [document.documentElement.clientWidth+'px', document.documentElement.clientHeight + 'px'],
            fixed: false,
            content: [url, 'auto'],
            end: function () {
                searchList();
            }
        });
    }

    function searchList() {
        table.reload("table")
    }
</script>
</html>
